package com.le.tester.book.effectivejava3rdchinese.secondReading.l52;

/**
 * createTime：2024-10-12 10:23
 * description：继承类的方法重写
 */

class Wine {
    String name() {
        return "wine";
    }
}

class SparklingWine extends Wine {
    @Override
    String name() {
        return "sparkling wine";
    }
}

class Champagne extends SparklingWine {
    @Override
    String name() {
        return "champagne";
    }
}

public class Overriding {
    public static void main(String[] args) {
        //不再建议使用new String(),使用String.valueOf()
        //String.valueOf()
        System.out.println(new Wine().name());
        System.out.println(new SparklingWine().name());
        System.out.println(new Champagne().name());
    }
}
